<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
	<meta charset="utf-8">
	<meta name="keywords" content="" />
	<meta name="description" content="" />
	<meta content="width=device-width, minimum-scale=1,initial-scale=1, maximum-scale=1, user-scalable=1" id="viewport" name="viewport" />
	<meta content="yes" name="apple-mobile-web-app-capable" />
	<meta content="black" name="apple-mobile-web-app-status-bar-style" />
	<meta content="telephone=no" name="format-detection" />
	<link type="text/css" rel="stylesheet" href="../../template/css/com/com.css"/>
	<link type="text/css" rel="stylesheet" href="../../template/css/list/style.css"/>
	<link rel="stylesheet" href="../../resource/weuimin.css" />
    <link rel="stylesheet" href="../../resource/jinsuistyle.css" />
	<script src="../../template/js/jquery.js"></script>
    <script type="text/javascript" src="../../script/constants.js"></script>
	<script type="text/javascript" charset="UTF-8" src="../../script/naes.js"></script>
	<script src="../../script/api.js"></script>
    <style type="text/css">

    	body{
    	    background-color: #f1f1f1 !important;
    	}

      .qxmc{
         width:17%;
         display:block;
         float:left;

         text-align:center;
         margin-left: 2%
      }
      .qxmc-max{
       width:33%;
         display:block;
         float:left;
         text-align:center;
      }
      .cities{
        width:100%;
        font-size: small;
        line-height:25px;
        margin-top: 10px;
        border-bottom: 1px solid #005DA9;
        color: #005DA9;
        padding-left: 10px;
      }

          .item{
             width：100%；
             height:100px;
              border-bottom: 1px solid #aaaaaa;
          }
          .item, .text {
              display: -webkit-box;
          }

          .img {
              margin:8px;
              width: 84px;
              height: 84px;

          }
          .text-title{
            /*设置超过DIV后隐藏*/
              overflow: hidden;
              text-overflow: ellipsis;
              white-space: nowrap;

              margin-top: 5px;
              font-size: 18px;
              height: 25px;
              line-height: 25px;
              color: #000000;
          }

          img {
              width: 100%;
              display: block;
          }

          .text {
              -webkit-box-flex: 1;
              -webkit-box-orient: vertical;
              margin: 0 5px;
          }

          .text-price {
              padding: 2px 0;
          }

          .new-price {
              line-height:22px;
              font-size: 20px;
              color: red;
              font-family: Impact, Arail, sans-serif;
              font-weight: bold;
          }


        .address {
          /*设置超过DIV后隐藏*/
           overflow: hidden;
          text-overflow: ellipsis;
           white-space: nowrap;

          margin-left: 5px;
          line-height: 18px;
        }


        </style>
          <script type="text/javascript">
            var doubliSplierId=1;
            var phone=15680030061;
            var  cityCode = '';
            var  disCode = '';
            var cnt=0;
          window.apiready = function() {
              queryMyHotel();
              api.addEventListener({
                  name: 'RefreshQueryMyHotel'
              }, function(ret, err) {
                    queryMyHotel();
              });
          }

          //查询酒店
          function queryMyHotel() {
            var html =  "";
            $("#loadingToast").show();
                var callback = function(ret, err){

                            console.log(JSON.stringify(ret));
                            var data = ret.list;
                              for(i in data){
                                var url;
                                if(typeof(data[i].picUrl[0])=='undefined'){
                                  url="../../image/noimage.png";
                                }else {
                                    url=data[i].picUrl[0].URL;
                                }

                                html +='<div id="deleteBut'+i+'" style="margin-top:45px;height:55px;width:15%;background-color:#CCCCCC;float:left;'+
                                  'background:url(\'../../image/search_zc/delete.png\');background-size:100%;border-bottom: 1px solid #AAAAAA;display:none" onclick="deleteRoomByID(\''+data[i].cid+'\',\''+data[i].id+'\')"></div>'+
                                '    <div class="item" onclick="openMyRooms(\''+data[i].id+'\',\''+data[i].name+'\',\''+data[i].start+'\',\''+data[i].address+'\',\''+url+'\')">'+
                                      '<div class="img"><img src="'+url+'" style="height:100%;"></div>'+
                                      '<div class="text">'+
                                        '<div class="text-title">'+data[i].name+'<span style="font-size:medium;color:red;padding-left:8px;">'+data[i].start+'星</span></div>'+
                                        '<div class="text-price"><span class="new-price">￥'+data[i].minPrince+'</span><span style="color:red;line-height:0;">起</span></div>'+
                                        '<div class="address" style="color:ff7c70">已有'+data[i].amount+'人设置为我的酒店</div>'+
                                      '  <div class="address">地址：'+data[i].address+'</div>'+
                                      '</div>'+
                                  '  </div>' ;

                                    cnt++;
                                    // alert(html);
                              }
                  console.log(html);
                $("#hotelDiv").html(html);
                  $("#loadingToast").hide();
                    }
            var parameter = {"phone":phone,"cityCode":cityCode,"disCode":disCode};
                  apiAjax(JSON.stringify(parameter),url.myHotelList,callback);
          }

          //打开我的房间
          function openMyRooms(id,name,starLevel,address,picUrl) {
          api.openWin({
            name: 'my_hotel_rooms',
            url: './my_hotel_rooms.html',
            pageParam:{
              id:id,
              phone:phone,
              name:name,
              starLevel:starLevel,
              address:address,
              picUrl:picUrl

            }
            });
        }

          //
          //获取四川省酒店列表
         function opennima(){
               // cancel_starLevelAndPrice();
                  var callback = function(ret, err){
                     var cities = document.getElementById('cities');
                     //隐藏或展开城市列表
           if(cities.hidden){
             cities.hidden = false;
           }else{
             cities.hidden = true;
           }
                     var data = eval('('+ret.list+')');
                     var html;

                       html = '<tr>'+
                 '<th>'+
                   '<td style="width:20%;" onclick=openThisCity(0,"全部")>全部</td>'+
                   '<td style="width:20%;" onclick=openThisCity("'+data[0].DM+'","'+data[0].MC+'")>'+data[0].MC+'</td>'+
                   '<td style="width:20%;" onclick=openThisCity("'+data[1].DM+'","'+data[1].MC+'")>'+data[1].MC+'</td>'+
                   '<td style="width:20%;" onclick=openThisCity("'+data[2].DM+'","'+data[2].MC+'")>'+data[2].MC+'</td>'+
                   '<td style="width:20%;" onclick=openThisCity("'+data[13].DM+'","'+data[13].MC+'")>'+data[13].MC+'</td>'+
                 '</th>'+
               '</tr>'+
               '<tr>'+
                 '<th>'+

                   '<td onclick=openThisCity("'+data[6].DM+'","'+data[6].MC+'")>'+data[6].MC+'</td>'+
                   '<td onclick=openThisCity("'+data[7].DM+'","'+data[7].MC+'")>'+data[7].MC+'</td>'+
                   '<td onclick=openThisCity("'+data[8].DM+'","'+data[8].MC+'")>'+data[8].MC+'</td>'+
                   '<td onclick=openThisCity("'+data[9].DM+'","'+data[9].MC+'")>'+data[9].MC+'</td>'+
                   '<td onclick=openThisCity("'+data[14].DM+'","'+data[14].MC+'")>'+data[14].MC+'</td>'+
                 '</th>'+
               '</tr>'+
               '<tr>'+
                 '<th>'+
                   '<td onclick=openThisCity("'+data[16].DM+'","'+data[16].MC+'")>'+data[16].MC+'</td>'+
                   '<td onclick=openThisCity("'+data[17].DM+'","'+data[17].MC+'")>'+data[17].MC+'</td>'+
                   '<td onclick=openThisCity("'+data[18].DM+'","'+data[18].MC+'")>'+data[18].MC+'</td>'+
                   '<td onclick=openThisCity("'+data[19].DM+'","'+data[19].MC+'")>'+data[19].MC+'</td>'+
                   '<td onclick=openThisCity("'+data[20].DM+'","'+data[20].MC+'")>'+data[20].MC+'</td>'+
                 '</th>'+
               '</tr>'+
               '<tr>'+
                 '<th>'+
                   '<td onclick=openThisCity("'+data[15].DM+'","'+data[15].MC+'")>'+data[15].MC+'</td>'+
                   '<td onclick=openThisCity("'+data[5].DM+'","'+data[5].MC+'")>'+data[5].MC+'</td>'+
                   '<td onclick=openThisCity("'+data[3].DM+'","'+data[3].MC+'")>'+data[3].MC+'</td>'+
                   '<td  onclick=openThisCity("'+data[10].DM+'","'+data[10].MC+'")>'+data[10].MC+'</td>'+
                     '<td  onclick=openThisCity("'+data[4].DM+'","'+data[4].MC+'")>'+data[4].MC+'</td>'+
                 '</th>'+
               '</tr>'+
               '<tr>'+
                 '<th>'+
                   '<td  onclick=openThisCity("'+data[11].DM+'","'+data[11].MC+'")>'+data[11].MC+'</td>'+
                   '<td   colspan="3" onclick=openThisCity("'+data[12].DM+'","'+data[12].MC+'")>'+data[12].MC+'</td>'+
                 '</th>'+
               '</tr>';

               // line-height:25px;
               // margin-top: 10px;
               // border-bottom: 1px solid #005DA9;
               // color: #005DA9;
               // padding-left: 10px;

                     $("#cities").html(html);
                   }
                   var parameter = {"dm": "510000"};
                apiAjax(JSON.stringify(parameter),url.dzxx,callback);

         }

         /**
          *根据城市地址编码获取该市县级地区
          */
         function openThisCity(DM,MC){
           cityCode=DM;
           // disCode="";
           if(MC=="全部"){//这里设“全部”为四川省所有市级地区
             $("#openArea").text('四川省');
             cityCode = '';
             disCode = '';
             var cities = document.getElementById('cities');
             cities.hidden=true;
             queryMyHotel();
             return false;

           }else{
             $("#openArea").text(MC);

               var callback = function(ret, err){
                 var data = ret.list;
                 var cities = document.getElementById('cities');
                 var html="";
                 //判断返回数据量的大小，选择合适的排列方式
                   if(data.length<=18){
                     html += '<span class="qxmc-max" onclick=openThis(0,"全部","'+cityCode+'","'+MC+'")>全部</span>';
                     for(var i=0;i<data.length;i++){
                         if((i+1)!=0&&(i+1)%3==0){//换行
                           html +=  '<br/><span class="qxmc-max" onclick=openThis("'+data[i].DM+'","'+data[i].MC+'","'+cityCode+'","'+MC+'")>'+data[i].MC+'</span>'
                         }else{
                           html += '<span class="qxmc-max" onclick=openThis("'+data[i].DM+'","'+data[i].MC+'","'+cityCode+'","'+MC+'")>'+data[i].MC+'</span>'
                         }
                     }
                    //  html += '<br/><div style="margin-left:-15px;margin-bottom:-2px;width:120%;height:35px;background-color:#fff;border-top: 1px solid #005DA9;line-height:35px;font-size:18px"><div style="float:left;width:16px;height:16px;margin-left:15px;margin-top:8px;background:url(\'../../image/search_zc/myLocation.png\');background-size:100%"></div><div style="float:left">&nbsp&nbsp我的位置</div></div>'

                     $("#cities").html(html);
                   return false;
                   }
                   //判断返回数据量的大小，选择合适的排列方式
                 if(data.length>18){
                     html += '<span class="qxmc" onclick=openThis(0,"全部","'+cityCode+'","'+MC+'")>全部</span>';
                     for(var i=0;i<data.length;i++){
                       if((i+1)!=0&&(i+1)%5==0){
                         html +=  '<br/><span class="qxmc" onclick=openThis("'+data[i].DM+'","'+data[i].MC+'","'+cityCode+'","'+MC+'")>'+data[i].MC+'</span>'
                       }else{
                         html += '<span class="qxmc" onclick=openThis("'+data[i].DM+'","'+data[i].MC+'","'+cityCode+'","'+MC+'")>'+data[i].MC+'</span>'
                       }
                     }
                    //  html += '<br/><div style="margin-left:-15px;margin-bottom:-2px;width:120%;height:35px;background-color:#fff;border-top: 1px solid #005DA9;line-height:35px;font-size:18px"><div style="float:left;width:16px;height:16px;margin-left:15px;margin-top:8px;background:url(\'../../image/search_zc/myLocation.png\');background-size:100%"></div><div style="float:left">&nbsp&nbsp我的位置</div></div>'

                   $("#cities").html(html);
                   return false;
                 }
               }
           var parameter = {"areaCode":cityCode};
           apiAjax(JSON.stringify(parameter),url.queryAreaInCity,callback);
         }
       }


         /**
          *openThis 据地址编码获取某市县级地区
          *param disDM 县级地区编码
          *param MC 选中的地区名称、
         *param cityDM 市级地区编码
          *param cityMC 本来的市级地区名称
          */
         function openThis(disDM,MC,cityDM,cityMC){
           cityCode = cityDM;
           disCode = disDM;
           page = 1;
           if(MC=='全部'){//全市
             $("#openArea").text(cityMC);
             disCode = '';
             queryMyHotel();
           }else{
             $("#openArea").text(cityMC+MC);
             queryMyHotel();
             }
             var cities = document.getElementById('cities');
             cities.hidden = true;
         }

        //编辑我的酒店
         function editMyHotels() {
           if(cnt>0){
             if($('#deleteBut0').css('display')=='none'){
               $("#edit").html("取消编辑");
               for(var i=0;i<cnt;i++){
                 $("#deleteBut"+i).show();
               }
                 $("#roomsInfo").css("width","85%");
             }else if($('#deleteBut0').css('display')=='block'){
               $("#edit").html("编辑");
               for(var i=0;i<cnt;i++){
                 $("#deleteBut"+i).hide();
               }
                 $("#roomsInfo").css("width","100%");
             }

             }
         }

         function deleteRoomByID(cid,id) {
           if(window.confirm('你确定要删除该酒店吗？')){
             var callback = function(ret, err){
                         console.log(JSON.stringify(ret));
                         // alert(ret.success);
                         if(ret.success){
                           alert("删除成功");
                           $("#edit").html("编辑");
                           queryMyHotel();
                         }
                       }
                 var parameter = {"id":cid,"hotelId":id};
                   apiAjax(JSON.stringify(parameter),url.deleteMyHotel,callback);
                  return true;
               }else{
                  return false;
              }
           }




          </script>
 </head>
 <header id="statusBar">
       <div style="height:50px;background: #298cb4;display: table;width: 100%;">
          <div style="height:50px;line-height: 50px;color: #ffffff;background: #1e6887;">
              <div style="width: 26%;margin-left: 4%;font-size: 16px;float: left;" onclick="api.closeWin();">
            返回
            </div>
            <div style="text-align: center;font-weight:bold;width: 40%;font-size: 16px;float: left;">
            我的酒店
            </div>
            <div id="edit" style="width: 26%;margin-right: 4%;font-size: 16px;float: left;text-align: right" onclick="editMyHotels()">
            编辑
            </div>
            <!-- <div style="width: 26%;margin-right: 4%;font-size: 16px;float: left;text-align: right" onclick="">
            编辑
            </div> -->
          </div>
       </div>
 </header>
 <div style="width:100%;height:60px;background-color:#ffffff">
     <div style="width:100%;height:60x;float:left" onclick="opennima()">
         <div id="openArea" style="width:100%;height:40x;font-size:18px;line-height:40px;text-align:center;float:left;overflow: hidden;text-overflow: ellipsis;white-space: nowrap">四川省 </div>
         <div style="width:100%;height:20x;font-size:12px;line-height:20px;text-align:center;float:left">（商旅住宿）</div>
     </div>
 </div>
 <table id="cities"  class="cities" hidden >
 </table>

    <div id = "hotelDiv" style="display:block;">
    </div>

<!-- background:url('../../image/search_zc/location1.jpg')
		</div>
	</div> -->
	<!-- 加载动画 -->
	<div id="loadingToast" style="display:none;">
			<div class="weui-mask_transparent"></div>
			<div class="weui-toast">
				<i class="weui-loading weui-icon_toast"></i>
				<p class="weui-toast__content">数据加载中...</p>
			</div>
		</div>
	<!-- 公共底部，必须引用 -->

<!--			<div class="com-footer-area footer" id="js-com-footer" style="width:100%;height: 8%;">
				<img src="../../image/db.png" style="width:100%;"/>
			</div>-->

</body>

</html>
